/**
 * 
 */
package sailing.excel;

import java.util.HashMap;
import java.util.Map;

import sailing.entity.BankDepositsAccount;
import sailing.entity.BankStatement;
import sailing.entity.BillsDetail;
import sailing.entity.CashVoucher;
import sailing.entity.LoanAccount;
import sailing.entity.ReceivableDetail;
import sailing.entity.RunningAccount;
import sailing.excel.translators.BankDepositsAccountTranslator;
import sailing.excel.translators.BankStatementTranslator;
import sailing.excel.translators.BillsDetailTranslator;
import sailing.excel.translators.CashVoucherTranslator;
import sailing.excel.translators.LoanAccountTranslator;
import sailing.excel.translators.ReceivableDetailTranslator;
import sailing.excel.translators.RunningAccountTranslator;
import cjlite.logger.Logger;

/**
 * @author kevin
 * 
 */
public class ExcelParseFactory {

	private static Logger logger = Logger.thisClass();

	/**
	 * Entity Parse Class Map
	 */
	private static Map<Class<?>, Class<?>> parserMap = new HashMap<Class<?>, Class<?>>() {
		{
			this.put(CashVoucher.class, CashVoucherTranslator.class);
			this.put(BankDepositsAccount.class, BankDepositsAccountTranslator.class);
			this.put(ReceivableDetail.class, ReceivableDetailTranslator.class);
			this.put(LoanAccount.class, LoanAccountTranslator.class);
			this.put(RunningAccount.class, RunningAccountTranslator.class);
			this.put(BankStatement.class, BankStatementTranslator.class);
			this.put(BillsDetail.class, BillsDetailTranslator.class);
		}
	};

	/**
	 * Construct a Entity Data Parser
	 * 
	 * @param clazz
	 * @return
	 */
	public static <T> ExcelParser get(Class<T> clazz) {
		Class<?> parserClass = parserMap.get(clazz);
		if (parserClass == null) {
			logger.error("Parser class for {0} can not be null, Please config it...", clazz);
			return null;
		}
		ExcelParser ep = new ExcelParser(clazz, parserClass);

		return ep;
	}
}
